package com.campus.counseling.controller;

import com.campus.counseling.entity.CounselorAccount;
import com.campus.counseling.service.CounselorAccountService;
import com.campus.counseling.model.common.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@Api(tags = "咨询师账户管理")
@RestController
@RequestMapping("/counselor/account")
@RequiredArgsConstructor
public class CounselorAccountController {

    private final CounselorAccountService counselorAccountService;

    @ApiOperation("获取账户信息")
    @GetMapping("/info")
    public Result<CounselorAccount> getAccountInfo() {
        return Result.success(counselorAccountService.getCurrentCounselorAccount());
    }

    @ApiOperation("获取收入统计")
    @GetMapping("/income/stats")
    public Result<Object> getIncomeStats(@RequestParam String timeRange) {
        return Result.success(counselorAccountService.getIncomeStats(timeRange));
    }

    @ApiOperation("获取账户流水")
    @GetMapping("/flow")
    public Result<Object> getAccountFlow(
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10") Integer pageSize,
            @RequestParam(required = false) String flowType) {
        return Result.success(counselorAccountService.getAccountFlow(pageNum, pageSize, flowType));
    }

    @ApiOperation("获取待结算金额")
    @GetMapping("/pending-settlement")
    public Result<Object> getPendingSettlement() {
        return Result.success(counselorAccountService.getPendingSettlement());
    }

    @ApiOperation("获取历史结算记录")
    @GetMapping("/settlement/history")
    public Result<Object> getSettlementHistory(
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10") Integer pageSize) {
        return Result.success(counselorAccountService.getSettlementHistory(pageNum, pageSize));
    }
} 